package com.zmz.MD5;

import java.util.ArrayList;
import java.util.List;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/11/30/19:39
 * @Description: 敏感信息脱敏操作
 */
public class DesensitizedIdNumber {
    public static void main(String[] args) {
        System.out.println(desensitizedIdNumber("429004200102102"));
        test();
    }

    /*
     * @Description 证件号码脱敏操作，保留前三位后一位
     * @Param
     * @return
     **/
    private static String desensitizedIdNumber(String idNumber) {
        if (idNumber.length() == 15) {
            idNumber = idNumber.replaceAll("(\\w{3})\\w*(\\w{1})", "$1***********$2");
        }
        if (idNumber.length() == 18) {
            idNumber = idNumber.replaceAll("(\\w{3})\\w*(\\w{1})", "$1**************$2");
        }
        return idNumber;
    }

    private static void test() {
        List<String> a = new ArrayList<String>();
        a.add("a");
        a.add("b");
        a.add("c");
        a.add("d");
        System.out.println(a.size());
        if (3 < a.size()) {
            System.out.println(a.get(3));
        }
    }
}
